<?php
class Model_Admin_SiteUser extends Model{

    public function getInfo($name,$email,$offset,$rows){

        $total= DB::select(array(DB::expr('count(1)'), 'total'))

        ->from('site_user')->where("FullName",'like','%'.$name.'%')

        ->and_where("user_email",'like','%'.$email.'%')->execute()->get("total");

        $sql="select t.site_userid id,t.fullName username,t.user_email email,t.createdon
             from site_user t
             where t.FullName like '%$name%'
             and t.user_email like '%$email%'
             order by t.CreatedOn desc
             limit $offset,$rows";

         $data=DB::query(Database::SELECT,$sql)->execute()->as_array();

         return array("total"=>$total,"rows"=>$data);
    }

    public function getAdminUser(){

        $sql="select t.site_userid id,t.fullName username
            from site_user t
            where admin='1'
            order by t.CreatedOn desc";

        $data=DB::query(Database::SELECT,$sql)->execute()->as_array();
        return $data;
    }
}